import pkg from "crypto-js";
import { request } from "~/utils/http";
import type { ILoginResp, IProfile } from "./type";
const { MD5 } = pkg;

export const apiLogin = (data: {
  email: string;
  password: string;
}): Promise<ILoginResp> => {
  const time = Date.now();
  return request.post("/auth/login", {
    ...data,
    password: MD5(MD5(data.password).toString().toLowerCase() + time)
      .toString()
      .toLowerCase(),
    time,
  });
};

export const apiProfile = (): Promise<IProfile> => request.get("/auth/profile");
